<%--
  Created by IntelliJ IDEA.
  User: Ahuanlien
  Date: 2018/6/8
  Time: 12:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <%@include file="/static/common/commom.jsp" %>
    <script>
        $(function () {

            $("#permission_dataGrid").datagrid({
                url: "/permission/query.do",
                fitColumns: true,//列自适应
                fit: true,
                columns: [[
                    {field: 'name', title: '权限名称', width: 100},
                    {field: 'resource', title: '权限表达式', width: 100},
                ]],
                toolbar: "#tb",//工具
                pagination: true,//分页
                rownumbers: true,//行号
                singleSelect: true//只允许选择一行
            })

            var methodObj = {
                reload: function () {
                    $.messager.confirm("提示", "本次操作时间较长,是否要继续加载权限?", function (r) {
                        if (r) {
                            $.get("/permission/reload.do", function (data) {
                                if (data.success) {
                                    $.messager.alert("提示", "加载成功", "tip");
                                    $("#permission_dataGrid").datagrid("load");
                                } else {
                                    $.messager.alert("提示", "加载失败", "error");
                                }
                            })
                        }
                    })
                },
                refresh: function () {
                    $("#permission_dataGrid").datagrid("load");
                }
            }

            $("a[data-cmd]").click(function () {
                var cmd = $(this).data("cmd");
                methodObj[cmd]();
            })
        })
    </script>
</head>
<body>
<table id="permission_dataGrid"></table>
<!--工具栏-->
<div id="tb">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" data-cmd="reload">加载</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" data-cmd="refresh">刷新</a>
</div>
</body>
</html>